import {
  ResponseActivityFinishedQueryDto,
  ResponseListTask,
  Responselong,
  ResponseUserTaskQueryDto
} from '@/types/apiType';

import request from '../utils/request';
import { RequestConfig } from '../utils/request/type';

/**
 * @description
 * @tags 任务接口
 * @summary 任务列表
 * @request get:/api/task/list
 */
export const apiTaskListByGet = (
  params: { activityId: number; goodsId: number },
  config?: RequestConfig
) => request.get<ResponseListTask>(`/api/task/list`, params, config).then((res) => res?.result);

/**
 * @description
 * @tags 任务接口
 * @summary 卡片抽奖
 * @request get:/api/task/lotteryCard
 */
export const apiTaskLotteryCardByGet = (
  params: { activityId: number; goodsId: number; taskId: number },
  config?: RequestConfig
) =>
  request
    .get<ResponseUserTaskQueryDto>(`/api/task/lotteryCard`, params, config)
    .then((res) => res?.result);

/**
 * @description
 * @tags 任务接口
 * @summary 任务状态查询
 * @request get:/api/task/query
 */
export const apiTaskQueryByGet = (
  params: { activityId: number; goodsId: number; taskId: number },
  config?: RequestConfig
) =>
  request
    .get<ResponseUserTaskQueryDto>(`/api/task/query`, params, config)
    .then((res) => res?.result);

/**
 * @description
 * @tags 任务接口
 * @summary 活动商品已集成卡片信息
 * @request get:/api/task/reachCards
 */
export const apiTaskReachCardsByGet = (
  params: { activityId: number; goodsId: number },
  config?: RequestConfig
) =>
  request
    .get<ResponseActivityFinishedQueryDto>(`/api/task/reachCards`, params, config)
    .then((res) => res?.result);

/**
 * @description
 * @tags 任务接口
 * @summary 领取卡片
 * @request get:/api/task/receiveCard
 */
export const apiTaskReceiveCardByGet = (
  params: { activityId: number; goodsId: number; taskId: number },
  config?: RequestConfig
) =>
  request
    .get<ResponseUserTaskQueryDto>(`/api/task/receiveCard`, params, config)
    .then((res) => res?.result);

/**
 * @description
 * @tags 任务接口
 * @summary 未完成任务数
 * @request get:/api/task/unFinishedCount
 */
export const apiTaskUnFinishedCountByGet = (
  params: { activityId: number; goodsId: number },
  config?: RequestConfig
) =>
  request.get<Responselong>(`/api/task/unFinishedCount`, params, config).then((res) => res?.result);
